package com.bw.edu.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
public class DemoController {

    @RequestMapping("/demo")
    public Map<String,Object> demo(){
        Map<String,Object> map = new HashMap<>();
        map.put("status",0);
        map.put("hitSugarSelf",true);
        map.put("msg","");
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("categories",new String[]{"苹果","三星","华为","oppo","vivo","小米57"});
        HashMap ma1 = new HashMap();
        ma1.put("name","手机品牌");
        ma1.put("data",new Integer[]{100,200,300,400,500,600});

        objectObjectHashMap.put("Series",ma1);
        map.put("data",objectObjectHashMap);
        return map;

    }
    /**
     *
     * 洗一个接口返回如下数据
     * {
     *   "status": 0,
     *   "hitSugarSelf": true,
     *   "msg": "",
     *   "data": {
     *     "categories": [
     *       "苹果",
     *       "三星",
     *       "华为",
     *       "oppo",
     *       "vivo",
     *       "小米91"
     *     ],
     *     "series": [
     *       {
     *         "name": "手机品牌",
     *         "data": [
     *           9737,
     *           9556,
     *           6097,
     *           8486,
     *           7165,
     *           5010
     *         ]
     *       }
     *     ]
     *   }
     * }
     */
    @RequestMapping(value = "/demo01")
    public Map<String,Object> demo01(){
        Map<String,Object> map = new HashMap<>();
        map.put("status",0);
        map.put("hitSugarSelf",true);
        map.put("msg","");
        HashMap<Object, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("categories",new String[]{"苹果2","三星2","华为2","oppo2","vivo","小米57"});
        List<Map<String, Object> > series = new ArrayList<>();
        Map<String, Object> ma1 = new HashMap<>();
        ma1.put("name","手机品牌");
        ma1.put("data",new Integer[]{9737,9556,6097,8486,7165,5010});
        series.add(ma1);
        objectObjectHashMap.put("series",series);
        map.put("data",objectObjectHashMap);
        return map;
    }
}
